require("../css/exercise.less")
require("../fonts/iconfont.css")

//调用公共的foot组键
document.ready(function(){
    window.$utils.tabs(1);
    const BASE_URL='http://139.9.177.51:8099'
    const userId=JSON.parse(window.localStorage.getItem("user")).userId
    window.$http.get("/sports/allcourse?id="+userId,function(res){
      console.log(res);
   const latest=res.data.find(item=>item,latest===1)
   const latestBox=document.querySelector("#latest_box")
        latestBox.innerHTML = `
              <h3>最新课程</h3>
              <a href="introduce.html?id=${latest.courseId}">
                <div style="background-image: url(${BASE_URL + latest.imgurl})"></div>
                <h4>${latest.name}</h4>
                <p>${latest.desc}</p>
              </a>
            `
            const kecheng=document.querySelector("#kecheng")
            const classArr=res.data.filter(item=>item.latest !==1)
            let innerStr='<h3>课程</h3>'
            classArr.forEach(function(item){
                innerStr+=`
                  <a class="course" href="introduce.html?id=${item.courseId}">
                <div style="background-image: url(${BASE_URL + item.imgurl})"></div>
                <h4>${item.name}</h4>
                <p>${item.desc}</p>
              </a>
              `
              kecheng.innerHTML=innerStr
            })
        })
    
})

